package com.zhengdongzulin.zuke.app.main.mine

import android.content.Intent
import com.lxj.androidktx.core.putString
import com.lxj.androidktx.core.sp
import com.zhengdongzulin.zuke.R
import com.zhengdongzulin.zuke.app.login.ZKForgetActivity
import com.zhengdongzulin.zuke.app.main.ZKWebviewActivity
import com.zhengdongzulin.zuke.base.*
import com.zhengdongzulin.zuke.databinding.ZkActivitySettingBinding
import com.zhengdongzulin.zuke.ext.put
import com.zhengdongzulin.zuke.ext.start


/**
 * jeff
 * 设置
 * 2021-03-27 17:50:47
 */
class ZKSettingActivity : BaseActivity<BaseViewModel, ZkActivitySettingBinding>() {


    override fun getLayoutResId(): Int = R.layout.zk_activity_setting

    override fun initVM(): BaseViewModel = BaseViewModel()

    override fun initView() {
        setTitleContent("设置")
    }

    override fun initData() {

    }

    override fun initListener() {
        mView.logout.setOnClickListener {
            sp().putString("token", "")
            sp().putString("userInfo", "")
            sp().putString("change_home", "")
            mShareViewModel.userInfo.value = null
            mShareViewModel.token.value = null
            finish()
        }
        mView.changePwd.setOnClickListener {
            Intent().put("type", "change").start(this@ZKSettingActivity, ZKForgetActivity::class.java)
        }
        mView.service.setOnClickListener {
            Intent().put("type", "服务协议").start(this, ZKWebviewActivity::class.java)
        }
        mView.privacy.setOnClickListener {
            Intent().put("type", "隐私条款").start(this, ZKWebviewActivity::class.java)
        }
        mView.rlAboutUs.setOnClickListener {
            Intent().start(this, ZKAboutUsActivity::class.java)
        }
    }

    override fun startObserve() {
    }

    override fun onResume() {
        super.onResume()
        if (mShareViewModel.isSettingFinish.value != null && mShareViewModel.isSettingFinish.value!!) {
            mShareViewModel.isSettingFinish.value = false
            finish()
        }
    }

}